<!--
 * @Author: ChunLai
 * @Date: 2023-08-14 13:47:04
 * @LastEditTime: 2025-11-26 15:32:06
 * @Description: 字段释义
 * @FilePath: \01.latest-short-insure\src\views\form\components\FieldDescMode.vue
-->
<template>
  <div class="icon_w16" @click.stop="openDesc" v-if="showIcon">
    <MsImgIcon size="16" name="tip" />
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  name: "FieldDescMode",
  props: {
    field: {
      type: String,
      default: () => "",
    },
  },
  data() {
    return {};
  },
  components: {},
  computed: {
    ...mapGetters({
      field2Desc: "page/field2Desc",
      fieldDescConfig: "page/fieldDescConfig",
    }),
    getFieldLabel() {
      let res = "";
      if (this.field) {
        if (this.field == "validDateEnd") {
          res = "证件有效期止期";
        } else if (this.field == "crsIdType") {
          res = "中国税收居民";
        } else if (this.field == "socialInsuFlag") {
          res = "社保";
        } else if (this.field == "frontImg") {
          res = "证件照上传";
        }
      }
      return res;
    },
    getFieldDesc() {
      let res = "";
      if (this.field) {
        if (this.fieldDescConfig[`${this.field}`]) {
          const findObj = this.fieldDescConfig[`${this.field}`].find((ele) =>
            ele.label.includes(this.gysEngName)
          );
          if (findObj) {
            if (this.field == "validDateEnd") {
              let strDesc = "";
              if (findObj.descConfig.length > 0) {
                findObj.descConfig.forEach((item) => {
                  strDesc += `${item.desc}；<br><br>`;
                });
              }
              res = strDesc;
            } else if (this.field == "crsIdType") {
              if (findObj.descConfig) {
                res = findObj.descConfig;
              }
            } else if (this.field == "socialInsuFlag") {
              if (findObj.descConfig) {
                res = findObj.descConfig;
              }
            } else if (this.field == "frontImg") {
              if (findObj.descConfig) {
                res = findObj.descConfig;
              }
            }
          }
        }
        if (this.field2Desc.length > 0) {
          const find2Obj = this.field2Desc.find((e) => e.label == this.field);
          if (find2Obj) {
            res = find2Obj.desc;
          }
        }
      }
      return res;
    },
    showIcon() {
      let res = false;
      if (this.getFieldDesc) {
        res = true;
      }
      return res;
    },
  },
  watch: {},
  created() {},
  mounted() {},
  methods: {
    openDesc() {
      this.$store.commit("common/SET_FIELD_MEAN_CONT", {
        label: `${this.getFieldLabel}`,
        desc: `${this.getFieldDesc}`,
      });
    },
  },
};
</script>

<style lang="less" scoped>
.icon_w16 {
  display: flex;
  margin-left: 6px;
}
</style>
